use clap::Parser;
use crate::{Base64Subcommand, CmdExector, CsvOpts, GenPassOpts, TextSubcommand};
use crate::cli::HttpSubcommand;

impl CmdExector for SubCommand {
    async fn execute(self) -> anyhow::Result<()> {
        Ok(match self {
            SubCommand::Csv(opt) => {
                opt.execute().await?
            }
            SubCommand::Http(opt) => {
                opt.execute().await?
            }
            _ => {
                todo!()
            }
            // SubCommand::Base64(opt) => {
            //     opt.execute()
            // },
            // SubCommand::GenPass(opt) => {
            //     opt.execute()
            // },
            // SubCommand::Http(opt) => {
            //     opt.execute()
            // },
            // SubCommand::Text(opt) => {
            //     opt.execute()
            // },
        })
    }
}

#[derive(Debug, Parser)]
#[command(name = "rcli", version, author, about, long_about = None)]
pub struct Opts {
    #[command(subcommand)]
    pub cmd: SubCommand,

}

#[derive(Debug, Parser)]
pub enum SubCommand {
    #[command(name = "csv", about = "Convert CSV to JSON")]
    Csv(CsvOpts),
    #[command(name = "genpass", about = "")]
    GenPass(GenPassOpts),

    #[command(subcommand)]
    Base64(Base64Subcommand),

    #[command(subcommand)]
    Text(TextSubcommand),
    #[command(subcommand)]
    Http(HttpSubcommand),
}
